Repository navigation
fix(lab-ops-hub): return WHATWG-normalized URLs from the container validator (#633) - #644
Merged
Merged
Conversation
…lidator (#633) validate_crawl_url returned dot segments, host case and default ports verbatim, so the container recorded — and fetched — a different URL than the Worker for the same accepted target (/a/../b and /%2e%2e/admin went on the wire verbatim). Add _normalize_validated_url, applied at both return sites: _resolve_dot_segments resolves literal and %2e dot segments (any case, trailing dot segments become a trailing slash, no climbing above the root, empty segments and %252e data preserved), the host is ASCII-lowercased (IDN spelling kept, as before), and the port is canonicalized (scheme default dropped including leading-zero spellings, other ports stripped of leading zeros, empty port colon dropped). Redirect targets inherit the form via validate_crawl_url. Tests: Python battery + redirect-handler pin + fetcher end-to-end (resolved path reaches the server), TS pin of the Worker form. Differential vs the Worker validator under Bun: byte-identical returned URLs over the issue battery and a 1500-case fuzz over dot-segment/host-case/port spellings.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 3
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #633.
validate_crawl_urlin the container crawler (pkgs/lab-ops-hub/container/app.py) returned the caller's spelling with only the character-encoding fixes of #614/#615/#618 — no WHATWG normalization — while the Worker validator returnsu.toString(). For the same accepted target the two crawlers recorded and fetched different URLs:http://example.com/a/../bhttp://example.com/a/../bhttp://example.com/bhttp://example.com/%2e%2e/adminhttp://example.com/adminHTTP://EXAMPLE.COM/Pathhttp://EXAMPLE.COM/Pathhttp://example.com/Pathhttp://example.com:80/x,:080http://example.com/xThe fetcher consequence is the serious arm:
_fetch_crawlsent/a/../band/%2e%2e/adminon the wire verbatim, so an origin (or proxy/WAF) that routes on the raw request target serves the container a different resource than the Worker — and%2e%2eis the classic path-confusion spelling when one layer resolves it and another does not.Solution
New
_normalize_validated_url, applied at bothvalidate_crawl_urlreturn sites (DNS names and IP literals); redirect targets inherit it via_ValidatingRedirectHandler→validate_crawl_url._resolve_dot_segments: a segment is a single-dot segment iff it is.or%2e, a double-dot segment iff it is..,.%2e,%2e.or%2e%2e(any case). Single-dot drops, double-dot pops the previous segment, neither climbs above the root, and a trailing dot segment becomes an empty final segment (/a/.→/a/,/a/..→/,//%2e→//). Empty segments are preserved (//a//bverbatim,/a//../b→/a/b), and longer/double-encoded spellings are data, never double-decoded (%2e%2e%2e,%252e%252epass through). The path's;paramstail is rejoined before resolving, so a trailing..;foois data, not a double-dot segment.:080,:0443), any other port is stripped of leading zeros (:08080→:8080), and an empty port's colon is dropped (that one arm of lab-ops-hub: container validator returns empty path, empty port and empty userinfo un-normalized — recorded URL differs from the Worker #639 rides along with port canonicalization; lab-ops-hub: container validator returns empty path, empty port and empty userinfo un-normalized — recorded URL differs from the Worker #639's empty-path and empty-userinfo arms remain open).No verdict changes: blocked hosts in these spellings are still refused by the ordinary checks, for the right reason (#633's controls verified).
Verification
9298c5f2before the fix (all issue spellings returned verbatim)./b,/adminis what reaches the server), and a TS pin of the Worker form. Python 54/54, TS 37/37.app.pyreverted, exactly the 3 new Python tests fail.münchen.de, the Worker serializes punycode).ruff formatapplied. Single-repo: novalidate_crawl_url/validateCrawlUrlcopy exists in the opencode/openchamber/nix clones (grep-verified), so no cross-repo port is owed.Need help on this PR? Tag
@codesmith-botwith what you need.